package com.hao.shiro.service.impl;

import com.hao.shiro.service.SecurityService;
import com.hao.shiro.tools.DigestsUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * TODO
 *
 * @author 97472
 * @version 1.0
 * @date 2021/8/28 15:56
 */
public class SecurityServiceImpl implements SecurityService {
    public Map<String,String> findPasswordByLoginName(String loginName) {
        return DigestsUtil.encryptPassword("123");
    }

    public List<String> getRoleByLoginName(String loginName) {
        List<String> roles = new ArrayList<String>();
        if ("admin".equals(loginName)){
            roles.add("admin");
        }
        roles.add("dev");
        roles.add("prod");
        return roles;
    }

    public List<String> getPermissionByLoginName(String loginName) {
        List<String> permissions = new ArrayList<String>();
        if ("joy".equals(loginName)){
            permissions.add("order:del");
            permissions.add("order:add");
            permissions.add("order:select");
        }
        return permissions;
    }
}
